//
//  MonthTicketViewModel.m
//  didacar
//
//  Created by 度周末网络-王腾 on 15/12/22.
//  Copyright © 2015年 dzmmac. All rights reserved.
//

#import "MonthTicketViewModel.h"

@implementation MonthTicketViewModel
-(id)init{
    self.monthTicketList = [[NSMutableArray alloc ] init];
    return [super init];
}

/**
 *  加载月票的价格日历
 *
 *  @param resultBlock
 */
-(void)loadMonthTicketData:(DealDataResultBlock)resultBlock{
    NSMutableDictionary *postDic = [[NSMutableDictionary alloc ] init];

    [postDic setObj:USERINFOManager.getUserInfo.MemberId forKey:@"MemberId"];
    [postDic setObj:self.LineId forKey:@"LineId"];
    [postDic setObj:@(self.BCID) forKey:@"BCID"];
    [postDic setObj:@(self.StartStationId) forKey:@"StartStationId"];
    [postDic setObj:@(self.EndStationId) forKey:@"EndStationId"];
    
    
    WEAKSELF
    [[BaseHttpRequest sharedInstance] sendRequestToPost:MonthTicket withData:postDic alertMessage:@"" success:^(NSDictionary *dicData) {
        
        // 上下车站点信息。不包含拐角
        [weakSelf.monthTicketList removeAllObjects];
        
        NSArray *array = [dicData objectForKey:@"monthTicketList"];
        for (NSInteger i = 0; i < array.count; i ++) {
            MonthTicketModel *monthTicketModel = [[MonthTicketModel alloc ] initWithDictionary:[array objectAtIndex:i]];
            [weakSelf.monthTicketList addObject:monthTicketModel];
        }
       
        resultBlock(1,nil,nil);
        
    } error:^(NSString *errorMsg) {
        resultBlock(0,nil,errorMsg);
    }];

}

@end
